<template>
    <div>
        <template v-if="action == 'edit' || action == 'search' ">
            <span>不建议使用</span>
        </template>
        <template v-if="action == 'table'">
            <div>
                <div style="color:rgba(0,0,0,0.54);">下单时间: {{data.created_at | datereg}}</div>
                <div>时间差: {{changeMinites}}分钟</div>
            </div>
        </template>
    </div>
</template>
<script>
    import base from '../base.js';
    import MapSelectAddress from '../../map/map-init.vue'
    export default {
        extends: base,
        props: {},
        components:{
            MapSelectAddress
        },
        data() {
            return {
                changeHours: 0,
                changeMinites: 0,
                changeSeconds: 0
            }
        },
        filters: {
            datereg(val) {
                if (val) {
                    return val.slice(5, 16);
                }
            },
            dateregc(val) {
                if (val) {
                    return val.slice(10, 16);
                }
            }
        },
        computed: {
        },
        watch: {
            data: {
                handler:function (val) {
                    this.setNowDate();
                },
                deep:true
            },
        },
        created() {
            this.setNowDate();
        },
        methods: {
            setNowDate() {
                let created_at_timestrop = this.data.created_at_timestamp * 1000;
                let nowTime = new Date().getTime();
                let changeTime = nowTime - created_at_timestrop;
                this.changeMinites =parseInt(changeTime/1000/60/60/24) * 24 * 60 + parseInt(changeTime/1000/60/60%24) * 60 + parseInt(changeTime/1000/60%60);
                this.changeSeconds = parseInt(changeTime/1000%60);
            }
        }
    }
</script>
<style lang='less' scoped>
</style>
